home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / ELISP.18 < prev    next >
Text File  |  1994-09-21  |  52KB  |  1,199 lines

  1. Info file elisp, produced by Makeinfo, -*- Text -*- from input file
  2. elisp.texi.
  3.  
  4.    This file documents GNU Emacs Lisp.
  5.  
  6.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual,   for
  7. Emacs Version 18.
  8.  
  9.    Published by the Free Software Foundation, 675 Massachusetts
  10. Avenue,  Cambridge, MA 02139 USA
  11.  
  12.    Copyright (C) 1990 Free Software Foundation, Inc.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of
  15. this manual provided the copyright notice and this permission notice
  16. are preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Foundation.
  27.  
  28.  
  29. 
  30. File: elisp,  Node: Commands for Insertion,  Next: Deletion,  Prev: Insertion,  Up: Text
  31.  
  32. User-Level Insertion Commands
  33. =============================
  34.  
  35.    This section describes higher-level commands for inserting text,
  36. commands intended primarily for the user but useful also in Lisp
  37. programs.
  38.  
  39.  * Command: insert-buffer FROM-BUFFER-OR-NAME
  40.      This function inserts the entire contents of FROM-BUFFER-OR-NAME
  41.      (which must exist) into the current buffer after point.  It
  42.      leaves the mark after the inserted text.  The value is
  43.      unpredictable.
  44.  
  45.  * Command: quoted-insert COUNT
  46.      This function reads the next input character verbatim and
  47.      inserts it.  It is primarily useful for inserting control
  48.      characters.  You may also type up to 3 octal digits, to insert a
  49.      character with that code.
  50.  
  51.      The argument COUNT is the number of these characters to insert. 
  52.      An error is signaled if COUNT is not a number.
  53.  
  54.      This function is primarily for interactive use; there is no
  55.      reason to use it in a program except for installing it on a
  56.      keymap.  It returns `nil'.
  57.  
  58.  * Command: self-insert-command COUNT
  59.      This function inserts the last character typed COUNT times and
  60.      returns `nil'.  This is the function that most printing
  61.      characters are bound to.  In routine use, `self-insert-command'
  62.      is the most frequently called function in Emacs, but programs
  63.      rarely use it except to install it on a keymap.
  64.  
  65.      In an interactive call, COUNT is the numeric prefix argument.
  66.  
  67.      This function calls `auto-fill-hook' if the current column
  68.      number is greater than the value of `fill-column' and the
  69.      character inserted is a space (*note Auto Filling::.).
  70.  
  71.      This function performs abbrev expansion if Abbrev mode (*note
  72.      Abbrevs::.) is enabled and the inserted character does not have
  73.      word-constituent syntax (*note Syntax Class Table::.).
  74.  
  75.      This function is also responsible for calling the
  76.      `blink-paren-hook' when the inserted character has close
  77.      parenthesis syntax (*note Blinking::.).
  78.  
  79.  * Command: newline &optional NUMBER-OF-NEWLINES
  80.      This function inserts newlines into the current buffer before
  81.      point.  If NUMBER-OF-NEWLINES is supplied, that many newline
  82.      characters are inserted.
  83.  
  84.      In Auto Fill mode, `newline' can break the preceding line if
  85.      NUMBER-OF-NEWLINES is not supplied.  When this happens, it
  86.      actually inserts two newlines at different places: one at point,
  87.      and another earlier in the line.  `newline' does not auto-fill
  88.      if NUMBER-OF-NEWLINES is non-`nil'.
  89.  
  90.      The value returned is `nil'.  In an interactive call, COUNT is
  91.      the numeric prefix argument.
  92.  
  93.  * Command: split-line
  94.      This function splits the current line, moving the portion of the
  95.      line after point down vertically, so that it is on the next line
  96.      directly below where it was before.  Whitespace is inserted as
  97.      needed at the beginning of the lower line, using the `indent-to'
  98.      function.  `split-line' returns the position of point.
  99.  
  100.      Programs hardly ever use this function.
  101.  
  102.  * Command: open-line COUNT
  103.      This function inserts COUNT newlines into the current buffer
  104.      after point, leaving point where it was.
  105.  
  106.      In an interactive call, COUNT is the numeric prefix argument. 
  107.      Programs hardly ever use this function.  The value is
  108.      unpredictable.
  109.  
  110.  * Command: overwrite-mode ARGUMENT
  111.      This function turns Overwrite mode on or off.  If ARGUMENT is
  112.      `nil' then the mode is toggled.  Otherwise, if ARGUMENT is a
  113.      positive number (greater than zero), then the mode is turned on;
  114.      any other argument turns it off.
  115.  
  116.      When Overwrite mode is on, self-inserting graphic characters
  117.      replace existing text character for character, and do not push
  118.      the existing text to the right.
  119.  
  120.      This function affects primarily `self-insert-command'.
  121.  
  122.      In an interactive call, ARGUMENT is set to the raw prefix
  123.      argument.  The return value of `overwrite-mode' is unpredictable.
  124.  
  125.  * Variable: overwrite-mode
  126.      Overwrite mode is in effect when this variable is non-`nil'.  It
  127.      is automatically made buffer-local when set in any fashion.
  128.  
  129.  
  130. 
  131. File: elisp,  Node: Deletion,  Next: User-Level Deletion,  Prev: Commands for Insertion,  Up: Text
  132.  
  133. Deletion of Text
  134. ================
  135.  
  136.    All of the deletion functions operate on the current buffer, and
  137. all return a value of `nil'.  In addition to these functions, you can
  138. also delete text using the "kill" functions that save it in the kill
  139. ring for the user; some of these functions save text in the kill ring
  140. in some cases but not in the usual case.  *Note The Kill Ring::.
  141.  
  142.  * Function: erase-buffer
  143.      This function deletes the entire text of the current buffer,
  144.      leaving it empty.  If the buffer is read-only, it signals a
  145.      `buffer-read-only' error.  Otherwise the text is deleted with no
  146.      confirmation required.  The value is always `nil'.
  147.  
  148.      As a safety measure, this function is not interactively callable.
  149.  
  150.  * Command: delete-region START END
  151.      This function deletes the text in the current buffer in the
  152.      region defined by START and END.  The value is `nil'.
  153.  
  154.  * Command: delete-char COUNT &optional KILLP
  155.      This function deletes COUNT characters directly after point, or
  156.      before point if COUNT is negative.  If KILLP is non-`nil', then
  157.      it saves the deleted characters in the kill ring.
  158.  
  159.      In an interactive call, COUNT is the numeric prefix argument,
  160.      and KILLP is the unprocessed prefix argument.  Therefore, if a
  161.      prefix argument is supplied, the text is saved in the kill ring.
  162.      If no prefix argument is supplied, then one character is
  163.      deleted, but not saved in the kill ring.
  164.  
  165.      The value returned is always `nil'.
  166.  
  167.  * Command: delete-backward-char COUNT &optional KILLP
  168.      This function deletes COUNT characters directly before point, or
  169.      after point if COUNT is negative.  If KILLP is non-`nil', then
  170.      it saves the deleted characters in the kill ring.
  171.  
  172.      In an interactive call, COUNT is the numeric prefix argument,
  173.      and KILLP is the unprocessed prefix argument.  Therefore, if a
  174.      prefix argument is supplied, the text is saved in the kill ring.
  175.      If no prefix argument is supplied, then one character is
  176.      deleted, but not saved in the kill ring.
  177.  
  178.      The value returned is always `nil'.
  179.  
  180.  * Command: backward-delete-char-untabify COUNT &optional KILLP
  181.      This function deletes COUNT characters backward, changing tabs
  182.      into spaces.  When the next character to be deleted is a tab, it
  183.      is first replaced with the proper number of spaces to preserve
  184.      alignment and then one of those spaces is deleted instead of the
  185.      tab.  If KILLP is non-`nil', then the command saves the deleted
  186.      characters in the kill ring.
  187.  
  188.      If COUNT is negative, then tabs are not changed to spaces, and
  189.      the characters are deleted by calling `delete-backward-char'
  190.      with COUNT.
  191.  
  192.      In an interactive call, COUNT is the numeric prefix argument,
  193.      and KILLP is the unprocessed prefix argument.  Therefore, if a
  194.      prefix argument is supplied, the text is saved in the kill ring.
  195.      If no prefix argument is supplied, then one character is
  196.      deleted, but not saved in the kill ring.
  197.  
  198.      The value returned is always `nil'.
  199.  
  200.  
  201. 
  202. File: elisp,  Node: User-Level Deletion,  Next: The Kill Ring,  Prev: Deletion,  Up: Text
  203.  
  204. User-Level Deletion Commands
  205. ============================
  206.  
  207.    This section describes higher-level commands for deleting text,
  208. commands intended primarily for the user but useful also in Lisp
  209. programs.
  210.  
  211.  * Command: delete-horizontal-space
  212.      This function deletes all spaces and tabs around point.  It
  213.      returns `nil'.
  214.  
  215.      In the following examples, assume that `delete-horizontal-space'
  216.      is called four times, once on each line, with point between the
  217.      second and third characters on the line.
  218.  
  219.           ---------- Buffer: foo ----------
  220.           I -!-thought
  221.           I -!-     thought
  222.           We-!- thought
  223.           Yo-!-u thought
  224.           ---------- Buffer: foo ----------
  225.           
  226.           (delete-horizontal-space)   ; Four times.
  227.                => nil
  228.           
  229.           ---------- Buffer: foo ----------
  230.           Ithought
  231.           Ithought
  232.           Wethought
  233.           You thought
  234.           ---------- Buffer: foo ----------
  235.  
  236.  * Command: delete-indentation &optional JOIN-FOLLOWING-P
  237.      This function joins the line point is on to the previous line,
  238.      deleting any whitespace at the join and in some cases replacing
  239.      it with one space.  If JOIN-FOLLOWING-P is non-`nil',
  240.      `delete-indentation' joins this line to following line instead. 
  241.      The value is `nil'.
  242.  
  243.      In the example below, point is located on the line starting
  244.      `events', and it makes no difference if there are trailing
  245.      spaces in the preceding line.
  246.  
  247.           ---------- Buffer: foo ----------
  248.           When in the course of human
  249.           -!-    events, it becomes necessary
  250.           ---------- Buffer: foo ----------
  251.           
  252.           (delete-indentation)
  253.                => nil
  254.           
  255.           ---------- Buffer: foo ----------
  256.           When in the course of human-!- events, it becomes necessary
  257.           ---------- Buffer: foo ----------
  258.  
  259.      After the lines are joined, the function `fixup-whitespace' is
  260.      responsible for deciding whether to leave a space at the junction.
  261.  
  262.  * Function: fixup-whitespace
  263.      This function replaces white space between the objects on either
  264.      side of point with either one space or no space as appropriate. 
  265.      It returns `nil'.
  266.  
  267.      The appropriate amount of space is none at the beginning or end
  268.      of the line.  Otherwise, it is one space except when point is
  269.      before a character with close parenthesis syntax or after a
  270.      character with open parenthesis or expression-prefix syntax. 
  271.      *Note Syntax Class Table::.
  272.  
  273.      In the example below, point is at the beginning of the second
  274.      line when `fixup-whitespace' is called the first time.  It is
  275.      located directly after the `(' for the second invocation.
  276.  
  277.           ---------- Buffer: foo ----------
  278.           This has too many spaces
  279.           -!-     at the front of this line
  280.           This has too many spaces at the start of (-!-   this list)
  281.           ---------- Buffer: foo ----------
  282.           
  283.           (fixup-whitespace)
  284.                => nil
  285.           (fixup-whitespace)
  286.                => nil
  287.           
  288.           ---------- Buffer: foo ----------
  289.           This has too many spaces
  290.           at the front of this line
  291.           This has too many spaces at the start of (this list)
  292.           ---------- Buffer: foo ----------
  293.  
  294.  * Command: just-one-space
  295.      This command replaces any spaces and tabs around point with a
  296.      single space.  It returns `nil'.
  297.  
  298.  * Command: delete-blank-lines
  299.      This function deletes blank lines surrounding point.  If point
  300.      is on a blank line with one or more blank lines before or after
  301.      it, then all but one of them are deleted.  If point is on an
  302.      isolated blank line, then it is deleted.  If point is on a
  303.      nonblank line, the command deletes all blank lines following it.
  304.  
  305.      A blank line is defined as a line containing only tabs and spaces.
  306.  
  307.      `delete-blank-lines' returns `nil'.
  308.  
  309.  
  310. 
  311. File: elisp,  Node: The Kill Ring,  Next: Undo,  Prev: User-Level Deletion,  Up: Text
  312.  
  313. The Kill Ring
  314. =============
  315.  
  316.    "Kill" functions delete text like the deletion functions, but save
  317. it so that the user can reinsert it by "yanking".  Most of these
  318. functions have `kill-' in their name.  By contrast, the functions
  319. whose names start with `delete-' normally do not save text for
  320. yanking (though they can still be undone); these are "deletion"
  321. functions.
  322.  
  323.    Most of the kill commands are primarily for interactive use, and
  324. are not described here.  What we do describe are the functions
  325. provided for use in writing such commands.  When deleting text for
  326. internal purposes within a Lisp function, you should normally use
  327. deletion functions, so as not to disturb the kill ring contents. 
  328. *Note Deletion::.
  329.  
  330.    Emacs saves the last several batches of killed text in a list.  We
  331. call it the "kill ring" because, in yanking, the elements are
  332. considered to be in a cyclic order.  The list is kept in the variable
  333. `kill-ring', and can be operated on with the usual functions for
  334. lists; there are also specialized functions, described in this
  335. section, which treat it as a ring.
  336.  
  337.    Some people think use of the word "kill" in Emacs is unfortunate,
  338. since it refers to processes which specifically *do not* destroy the
  339. entities "killed".  This is in sharp contrast to ordinary life, in
  340. which death is permanent and "killed" entities do not come back to
  341. life.  Therefore, other metaphors have been proposed.  For example,
  342. the term "cut ring" makes sense to people who, in pre-computer days,
  343. used scissors and paste to cut up and rearrange manuscripts. 
  344. However, it would be difficult to change now.
  345.  
  346. * Menu:
  347.  
  348. * Data in Kill Ring::   What text looks like in the kill ring.
  349. * Kill Functions::      Functions that kill text.
  350. * Yank Commands::       Commands that access the kill ring.
  351. * Kill Ring Internals:: Variables that hold kill-ring data.
  352.  
  353.  
  354. 
  355. File: elisp,  Node: Data in Kill Ring,  Next: Kill Functions,  Prev: The Kill Ring,  Up: The Kill Ring
  356.  
  357. Data Structures in the Kill Ring
  358. --------------------------------
  359.  
  360.    Killed text is kept as strings in a list.  A short kill ring, for
  361. example, might look like this:
  362.  
  363.      ("some text" "a different piece of text" "yet more text")
  364.  
  365.    Functions that push more text into the list make the text in
  366. question into a string (using `buffer-substring'), add the string to
  367. the front of the list, and then look at the length of the list.  If
  368. the length is longer than the value of `kill-ring-max', the last
  369. entry in the list is dropped off when the new entry is put on.
  370.  
  371.    The `kill-ring-yank-pointer' global variable points to the kill
  372. ring entry that a "yank" function will copy.  Several functions move
  373. this pointer from one entry to another, and a user can thereby
  374. specify which entry to copy.
  375.  
  376.    Here is a diagram that shows the variable `kill-ring-yank-pointer'
  377. pointing to the second entry in the kill ring `("some text" "a
  378. different piece of text" "yet more text")'.
  379.  
  380.      kill-ring       kill-ring-yank-pointer
  381.        |               |
  382.        |     ___ ___    --->  ___ ___      ___ ___
  383.         --> |___|___|------> |___|___|--> |___|___|--> nil
  384.               |                |            |            
  385.               |                |            |            
  386.               |                |             -->"yet more text" 
  387.               |                |
  388.               |                 --> "a different piece of text" 
  389.               |
  390.                --> "some text"
  391.  
  392. (This circumstance occurs after `C-y' (`yank') is immediately
  393. followed by `M-y' (`yank-pop').)
  394.  
  395.    Both `kill-ring' and `kill-ring-yank-pointer' are Lisp variables
  396. whose values are normally lists.  The word "pointer" in the name of
  397. the `kill-ring-yank-pointer' indicates that the variable's purpose is
  398. to identify one element of the list that will be used by default by
  399. the next yank command.  The value of `kill-ring-yank-pointer' is
  400. always `eq' to one of the links in the kill ring list.  The element
  401. it identifies is the CAR of that link.
  402.  
  403.    Moving `kill-ring-yank-pointer' to a different link is called
  404. "rotating the kill ring".  The functions that do this treat the kill
  405. ring (which is a list) as ring; that is to say, a change that would
  406. otherwise move the pointer past the end of the list (which would be
  407. useless) instead moves the pointer to the first link on the list. 
  408. Likewise, moving back from the first link goes to the last one.
  409.  
  410.    `kill-region' is the primitive method of killing text.  Any
  411. command that calls this function is a "kill command" (and should
  412. probably have the word "kill" in its name).  `kill-region' puts the
  413. newly killed text in a new element at the beginning of the
  414. `kill-ring' list, and then sets `kill-ring-yank-pointer' to point to
  415. the first link of the list, which contains the first element. 
  416. Consequently, the next `yank' command will yank the text just killed.
  417. In this situation, `kill-ring' and `kill-ring-yank-pointer' are `eq'
  418. to each other.
  419.  
  420.    When kill commands are interwoven with other commands, the killed
  421. portions of text are put into separate entries in the kill ring.  But
  422. when two or more kill commands are executed in sequence, the text
  423. killed by the second (or third, etc.) kill command is appended to the
  424. text killed by the first command so as to make one entry in the kill
  425. ring.  The `kill-region' function uses the `last-command' variable to
  426. keep track of whether the previous was a kill command, and in such
  427. cases appends the killed text to the most recent entry.
  428.  
  429.  
  430. 
  431. File: elisp,  Node: Kill Functions,  Next: Yank Commands,  Prev: Data in Kill Ring,  Up: The Kill Ring
  432.  
  433. Functions for Killing
  434. ---------------------
  435.  
  436.  * Command: kill-region START END
  437.      This function kills the text in the region defined by START and
  438.      END.  The text is deleted but saved in the kill ring.  The value
  439.      is always `nil'.
  440.  
  441.      In an interactive call, START and END are point and the mark.
  442.  
  443.  * Command: kill-line &optional COUNT
  444.      This function kills the rest of the line following point, not
  445.      including the newline.  If point is directly before a newline,
  446.      or if there is only whitespace between point and the newline,
  447.      then it kills the whitespace and newline.
  448.  
  449.      If COUNT is supplied, then the command kills that many lines
  450.      (*including* the newline).  (This makes executing `(kill-line
  451.      2)' different from executing `(kill-line)' twice.)  If COUNT is
  452.      negative, then `kill-line' kills lines backwards.
  453.  
  454.      In an interactive call, COUNT is the raw prefix argument (which
  455.      then gets converted to a number if non-`nil').  The value is
  456.      always `nil'.
  457.  
  458.  * Command: zap-to-char COUNT CHARACTER
  459.      In Emacs version 18, this function kills the text from point up
  460.      to *but not including* the specified character.  Thus, if the
  461.      cursor is at the beginning of this sentence and the character is
  462.      `s', `Thu' is deleted.  If the argument is 2, `Thus, if the cur'
  463.      is deleted, up to but not including the `s' in `cursor'.
  464.  
  465.      In Emacs version 19, this function will kill all text in the
  466.      region from point up to and including the next COUNT occurrences
  467.      of CHARACTER.  Thus, in the example shown in the previous
  468.      paragraph, the terminating `s' *will* be removed.
  469.  
  470.      The version 18 implementation kills text to the end of the
  471.      buffer if the specified character is not found, but the version
  472.      19 implementation will simply signal an error.
  473.  
  474.      The function scans backward from point if COUNT is negative. 
  475.      The value is always `nil'.
  476.  
  477.  * Command: copy-region-as-kill START END
  478.      This function saves the region defined by START and END on the
  479.      kill ring, but does not delete the text from the buffer.  It
  480.      returns `nil'.
  481.  
  482.      In an interactive call, START and END are point and the mark.
  483.  
  484.  
  485. 
  486. File: elisp,  Node: Yank Commands,  Next: Kill Ring Internals,  Prev: Kill Functions,  Up: The Kill Ring
  487.  
  488. Functions for Yanking
  489. ---------------------
  490.  
  491.  * Command: yank &optional ARG
  492.      This function inserts the text in the first entry in the kill
  493.      ring directly before point.  After the yank, the mark is
  494.      positioned at the beginning and point is positioned after the
  495.      end of the inserted text.
  496.  
  497.      If ARG is a list (which occurs interactively when the user types
  498.      `C-u' with no digits), then `yank' inserts the text as described
  499.      above, but puts point before the yanked text and puts the mark
  500.      after it.  If ARG is a number, then `yank' inserts the ARGth
  501.      most recently killed text.
  502.  
  503.      `yank' does not alter the contents of the kill ring or rotate it.
  504.      It returns `nil'.
  505.  
  506.  * Command: yank-pop ARG
  507.      This function replaces the just-yanked text with another batch
  508.      of killed text--another element of the kill ring.
  509.  
  510.      This command is allowed only immediately after a `yank' or a
  511.      `yank-pop'.  At such a time, the region contains text that was
  512.      just inserted by the previous `yank'.  `yank-pop' deletes that
  513.      text and inserts in its place a different stretch of killed
  514.      text.  The text that is deleted is not inserted into the kill
  515.      ring, since it is already in the kill ring somewhere.
  516.  
  517.      If ARG is `nil', then the existing region contents are replaced
  518.      with the previous element of the kill ring.  If ARG is numeric,
  519.      then the ARG'TH previous kill is the replacement.  If ARG is
  520.      negative, a more recent kill is the replacement.
  521.  
  522.      The sequence of kills in the kill ring wraps around, so that
  523.      after the oldest one comes the newest one, and before the newest
  524.      one goes the oldest.
  525.  
  526.      The value is always `nil'.
  527.  
  528.  
  529. 
  530. File: elisp,  Node: Kill Ring Internals,  Prev: Yank Commands,  Up: The Kill Ring
  531.  
  532. Internals of the Kill Ring
  533. --------------------------
  534.  
  535.    This section describes the lower levels of the kill ring.
  536.  
  537.  * Variable: kill-ring
  538.      List of killed text sequences, most recently killed first.
  539.  
  540.  * Variable: kill-ring-yank-pointer
  541.      This variable's value indicates which element of the kill ring
  542.      is the "front" of the ring.  More precisely, the value is a
  543.      sublist of the value of `kill-ring', and its CAR is the kill
  544.      string at the front of the ring.  Rotating the ring works by
  545.      changing `kill-ring-yank-pointer', and does not actually change
  546.      the value of `kill-ring'.
  547.  
  548.      Commands which do change the kill ring also copy the new kill
  549.      ring value into this variable.  The effect is to rotate the ring
  550.      so that the newly killed text is at front.
  551.  
  552.  * Command: rotate-yank-pointer COUNT
  553.      This function rotates the kill ring COUNT positions, which means
  554.      setting `kill-ring-yank-pointer' to some other link in the kill
  555.      ring list.  It returns the new value of `kill-ring-yank-pointer'.
  556.  
  557.  * User Option: kill-ring-max
  558.      The value of this variable is the maximum length to which the
  559.      kill ring can grow, before elements are thrown away on a
  560.      first-in, first-out basis.  The default value for
  561.      `kill-ring-max' is 30.
  562.  
  563.  
  564. 
  565. File: elisp,  Node: Undo,  Next: Filling,  Prev: The Kill Ring,  Up: Text
  566.  
  567. Undo
  568. ====
  569.  
  570.    Most buffers have an "undo stack" which records all changes made
  571. to the buffer's text so that they can be undone.  (In general, all
  572. buffers have undo stacks except special-purpose buffers for which
  573. Emacs assumes that undoing is not useful.)  The size of an undo stack
  574. is limited, so large changes or a large number of changes cannot be
  575. undone.
  576.  
  577.    Undoing an old change is itself a change, and is added to the undo
  578. stack.  However, you are not limited to undoing just the single most
  579. recent change; you can keep undoing older and older changes, even as
  580. the undo's themselves are being added to the stack.
  581.  
  582.  * Command: undo &optional ARG
  583.      This is a user-level command to undo some previous changes.  It
  584.      uses `undo-more' and `undo-start'.  By repeating this command
  585.      you can undo earlier and earlier changes, until the information
  586.      in the undo stack is used up.  A numeric argument serves as a
  587.      repeat count.  The value is unpredictable.
  588.  
  589.  * Function: undo-boundary
  590.      This function places a boundary between units of undo.  The undo
  591.      command stops at such a boundary, and successive undo commands
  592.      will undo to earlier and earlier boundaries.  The return value
  593.      is `nil'.
  594.  
  595.      The editor command loop automatically creates an undo boundary
  596.      between keystroke commands.  Thus, each undo normally undoes the
  597.      effects of one command.  Calling this function explicitly is
  598.      useful for splitting the effects of a command into more than one
  599.      unit.  For example, `query-replace' calls this function after
  600.      each replacement so that the user can undo individual
  601.      replacements one by one.
  602.  
  603.  * Function: undo-more COUNT
  604.      This function is used to undo COUNT additional units of undo. 
  605.      It is not safe if the buffer has been changed in any fashion
  606.      other than undo since the last call to `undo-start'.  Multiple
  607.      calls to `undo-more' have a cumulative effect, undoing farther
  608.      back in time.  The return value is `nil'.
  609.  
  610.  * Function: undo-start
  611.      This function prepares to undo one or more units of undo
  612.      describing the most recent changes to the current buffer.  It
  613.      does not actually undo anything (or change the buffer at all);
  614.      only `undo-more' does that.  It returns `nil'.
  615.  
  616.      One use of this function is to break a sequence of undo's, so a
  617.      subsequent call to `undo-more' will undo the recent run of
  618.      undoing, rather than extend it into the past.
  619.  
  620.      The command `undo' calls `undo-start' whenever the previous
  621.      command was not an `undo'.
  622.  
  623.  * Command: buffer-enable-undo &optional BUFFER-OR-NAME
  624.      This function assigns an undo stack for buffer BUFFER-OR-NAME,
  625.      so that subsequent changes can be undone.  If no argument is
  626.      supplied, then the current buffer is used.  If the buffer
  627.      already has an undo stack, nothing is changed.  This function
  628.      returns `nil'.
  629.  
  630.      In an interactive call, BUFFER-OR-NAME is the current buffer. 
  631.      You cannot specify any other buffer.
  632.  
  633.  * Function: buffer-flush-undo BUFFER
  634.      This function deassigns the undo stack of the buffer BUFFER, so
  635.      that it will not take up space.  As a result, it is no longer
  636.      possible to undo either previous changes or any subsequent
  637.      changes.  If the buffer already has no undo stack, then this
  638.      function has no effect.
  639.  
  640.      This function returns `nil'.  It cannot be called interactively.
  641.  
  642.  
  643. 
  644. File: elisp,  Node: Filling,  Next: Auto Filling,  Prev: Undo,  Up: Text
  645.  
  646. Filling
  647. =======
  648.  
  649.    "Filling" means adjusting the lengths of lines (by moving words
  650. between them) so that they are nearly (but no greater than) a
  651. specified maximum width.  Additionally, lines can be "justified",
  652. which means that spaces are inserted between words to make the line
  653. exactly the specified width.  The width is controlled by the variable
  654. `fill-column'.  For ease of reading, lines should be no longer than
  655. 70 or so columns.
  656.  
  657.    You can use Auto Fill mode (*note Auto Filling::.) to fill text
  658. automatically as you insert it, but changes to existing text may
  659. leave it improperly filled.  Then you must fill the text explicitly.
  660.  
  661.    Most of the functions in this section return values that are not
  662. meaningful.
  663.  
  664.  * Command: fill-paragraph JUSTIFY-FLAG
  665.      This function fills the paragraph at or after point.  If
  666.      JUSTIFY-FLAG is non-`nil', each line is justified as well.
  667.  
  668.  * Command: fill-region START END &optional JUSTIFY-FLAG
  669.      This function fills each of the paragraphs in the region from
  670.      start to end.  It justifies as well if JUSTIFY-FLAG is
  671.      non-`nil'.  (In an interactive call, this is true if there is a
  672.      prefix argument.)
  673.  
  674.      The variable `paragraph-separate' controls how to distinguish
  675.      paragraphs.
  676.  
  677.  * Command: fill-individual-paragraphs START END &optional
  678.           JUSTIFY-FLAG MAIL-FLAG
  679.      This function fills each paragraph in the region according to
  680.      its individual fill prefix.  Thus, if the lines of a paragraph
  681.      are indented with spaces, the filled paragraph will continue to
  682.      be indented in the same fashion.
  683.  
  684.      The first two arguments, START and END, are the beginning and
  685.      end of the region that will be filled.  The third and fourth
  686.      arguments, JUSTIFY-FLAG and MAIL-FLAG, are optional.  If
  687.      JUSTIFY-FLAG is non-`nil', the paragraphs are justified as well
  688.      as filled.  If MAIL-FLAG is non-`nil', the function is told that
  689.      it is operating on a mail message and therefore should not fill
  690.      the header lines.
  691.  
  692.  * Command: fill-region-as-paragraph START END &optional JUSTIFY-FLAG
  693.      This function considers a region of text as a paragraph and
  694.      fills it.  If the region was made up of many paragraphs, the
  695.      blank lines between paragraphs are removed.  This function
  696.      justifies as well as filling when JUSTIFY-FLAG is non-`nil'.  In
  697.      an interactive call, any prefix argument requests justification.
  698.  
  699.  * Command: justify-current-line
  700.      This function inserts spaces between the words of the current
  701.      line so that the line ends exactly at `fill-column'.  It returns
  702.      `nil'.
  703.  
  704.  * User Option: fill-column
  705.      This buffer-local variable specifies the maximum width of filled
  706.      lines.  Its value should be an integer, which is a number of
  707.      columns.  All the filling, justification and centering commands
  708.      are affected by this variable, including Auto Fill mode (*note
  709.      Auto Filling::.).
  710.  
  711.      As a practical matter, if you are writing text for other people
  712.      to read, you should set `fill-column' to no more than 70. 
  713.      Otherwise the line will be too long for people to read
  714.      comfortably, and this can make the text seem clumsy.
  715.  
  716.  * Variable: default-fill-column
  717.      The value of this variable is the default value for
  718.      `fill-column' in buffers that do not override it.  This is the
  719.      same as `(default-value 'fill-column)'.
  720.  
  721.      The default value for `default-fill-column' is 70.
  722.  
  723.  
  724. 
  725. File: elisp,  Node: Auto Filling,  Next: Sorting,  Prev: Filling,  Up: Text
  726.  
  727. Auto Filling
  728. ============
  729.  
  730.    "Filling" breaks text into lines that are no more than a specified
  731. number of columns wide.  Filled lines end between words, and
  732. therefore may have to be shorter than the maximum width.
  733.  
  734.    Auto Fill mode is a minor mode in which Emacs fills lines
  735. automatically as text as inserted.  This section describes the hook
  736. and the two variables used by Auto Fill mode.  For a description of
  737. functions that you can call manually to fill and justify text, see
  738. *Note Filling::.
  739.  
  740.  * Variable: auto-fill-hook
  741.      The value of this variable should be a function (of no
  742.      arguments) to be called after self-inserting a space at a column
  743.      beyond `fill-column'.  It may be `nil', in which case nothing
  744.      special is done.
  745.  
  746.      The default value for `auto-fill-hook' is `do-auto-fill', a
  747.      function whose sole purpose is to implement the usual strategy
  748.      for breaking a line.
  749.  
  750.      Since `auto-fill-hook' is not called by the `run-hooks'
  751.      function, it will be renamed `auto-fill-function' in Version 19.
  752.  
  753.  
  754. 
  755. File: elisp,  Node: Sorting,  Next: Indentation,  Prev: Auto Filling,  Up: Text
  756.  
  757. Sorting Text
  758. ============
  759.  
  760.    The sorting commands described in this section all rearrange text
  761. in a buffer.  This is in contrast to the function `sort', which
  762. rearranges the order of the elements of a list (*note
  763. Rearrangement::.).  The values returned by these commands are not
  764. meaningful.
  765.  
  766.  * Command: sort-regexp-fields REVERSE RECORD-REGEXP KEY-REGEXP START
  767.           END
  768.      This command sorts the region between START and END
  769.      alphabetically as specified by RECORD-REGEXP and KEY-REGEXP.  If
  770.      REVERSE is a negative integer, then sorting is in reverse order.
  771.  
  772.      Alphabetical sorting means that two sort keys are compared by
  773.      comparing the first characters of each, the second characters of
  774.      each, and so on.  If a mismatch is found, it means that the sort
  775.      keys are unequal; the sort key whose character is less at the
  776.      point of first mismatch is the lesser sort key.  The individual
  777.      characters are compared according to their numerical values. 
  778.      Since Emacs uses the ASCII character set, the ordering in that
  779.      set determines alphabetical order.
  780.  
  781.      The value of the RECORD-REGEXP argument specifies the textual
  782.      units or "records" that should be sorted.  At the end of each
  783.      record, a search is done for this regular expression, and the
  784.      text that matches it is the next record.  For example, the
  785.      regular expression `^.+$', which matches lines with at least one
  786.      character besides a newline, would make each such line into a
  787.      sort record.  *Note Regular Expressions::, for a description of
  788.      the syntax and meaning of regular expressions.
  789.  
  790.      The value of the KEY-REGEXP argument specifies what part of each
  791.      record is to be compared against the other records.  The
  792.      KEY-REGEXP could match the whole record, or only a part.  In the
  793.      latter case, the rest of the record has no effect on the sorted
  794.      order of records, but it is carried along when the record moves
  795.      to its new position.
  796.  
  797.      The KEY-REGEXP argument can refer to the text matched by a
  798.      subexpression of RECORD-REGEXP, or it can be a regular
  799.      expression on its own.
  800.  
  801.      If KEY-REGEXP is:
  802.  
  803.     `\DIGIT'
  804.           then the text matched by the DIGITth `\(...\)' parenthesis
  805.           grouping in RECORD-REGEXP is used for sorting.
  806.  
  807.     `\&'
  808.           then the whole record is used for sorting.
  809.  
  810.     a regular expression
  811.           then the function searches for a match for the regular
  812.           expression within the record.  If such a match is found, it
  813.           is used for sorting.  If a match for KEY-REGEXP is not
  814.           found within a record then that record is ignored, which
  815.           means its position in the buffer is not changed.  (The
  816.           other records may move around it.)
  817.  
  818.      For example, if you plan to sort all the lines in the region by
  819.      the first word on each line starting with the letter `f', you
  820.      should set RECORD-REGEXP to `^.*$' and set KEY-REGEXP to
  821.      `\<f\w*\>'.  The resulting expression looks like this:
  822.  
  823.           (sort-regexp-fields nil "^.*$" "\\<f\\w*\\>"
  824.                               (region-beginning)
  825.                               (region-end))
  826.  
  827.      If you call `sort-regexp-fields' interactively, you are prompted
  828.      for RECORD-REGEXP and KEY-REGEXP in the minibuffer.
  829.  
  830.  * Command: sort-subr REVERSE NEXTRECFUN ENDRECFUN &optional
  831.           STARTKEYFUN ENDKEYFUN
  832.      This command is the general text sorting routine that divides a
  833.      buffer into records and sorts them.  The functions `sort-lines',
  834.      `sort-paragraphs', `sort-pages', `sort-fields',
  835.      `sort-regexp-fields' and `sort-numeric-fields' all use
  836.      `sort-subr'.
  837.  
  838.      To understand how `sort-subr' works, consider the whole
  839.      accessible portion of the buffer as being divided into disjoint
  840.      pieces called "sort records".  A portion of each sort record
  841.      (perhaps all of it) is designated as the sort key.  The records
  842.      are rearranged in the buffer in order by their sort keys.  The
  843.      records may or may not be contiguous.
  844.  
  845.      Usually, the records are rearranged in order of ascending sort
  846.      key.  If the first argument to the `sort-subr' function,
  847.      REVERSE, is non-`nil', the sort records are rearranged in order
  848.      of descending sort key.
  849.  
  850.      The next four arguments to `sort-subr' are functions that are
  851.      called to move point across a sort record.  They are called many
  852.      times from within `sort-subr'.
  853.  
  854.        1. NEXTRECFUN is called with point at the end of a record. 
  855.           This function moves point to the start of the next record. 
  856.           The first record is assumed to start at the position of
  857.           point when `sort-subr' is called.  (Therefore, you should
  858.           usually move point to the beginning of the buffer before
  859.           calling `sort-subr'.)
  860.  
  861.        2. ENDRECFUN is called with point within a record.  It moves
  862.           point to the end of the record.
  863.  
  864.        3. STARTKEYFUN is called to move point from the start of a
  865.           record to the start of the sort key.  This argument is
  866.           optional.  If supplied, the function should either return a
  867.           non-`nil' value to be used as the sort key, or return `nil'
  868.           to indicate that the sort key is in the buffer starting at
  869.           point.  In the latter case, and ENDKEYFUN will be called to
  870.           find the end of the sort key.
  871.  
  872.        4. ENDKEYFUN is called to move point from the start of the
  873.           sort key to the end of the sort key.  This argument is
  874.           optional.  If STARTKEYFUN returns `nil' and this argument
  875.           is omitted (or `nil'), then the sort key extends to the end
  876.           of the record.  There is no need for ENDKEYFUN if
  877.           STARTKEYFUN returns a non-`nil' value.
  878.  
  879.      As an example of `sort-subr', here is the complete function
  880.      definition for `sort-lines':
  881.  
  882.           (defun sort-lines (reverse beg end)
  883.             "Sort lines in region alphabetically; arg means reverse order.
  884.           Called from a program, there are three arguments:
  885.           REVERSE (non-nil means reverse order),
  886.           and BEG and END (the region to sort)."
  887.             (interactive "P\nr")
  888.             (save-restriction
  889.               (narrow-to-region beg end)
  890.               (goto-char (point-min))
  891.               (sort-subr reverse 'forward-line 'end-of-line)))
  892.  
  893.      Here `forward-line' moves point to the start of the next record,
  894.      and `end-of-line' moves point to the end of record.  We do not
  895.      pass the arguments STARTKEYFUN and ENDKEYFUN, because the entire
  896.      record is used as the sort key.
  897.  
  898.      The `sort-paragraphs' function is very much the same, except
  899.      that its `sort-subr' call looks like this:
  900.  
  901.           (sort-subr reverse
  902.                      (function (lambda () (skip-chars-forward "\n \t\f")))
  903.                      'forward-paragraph)))
  904.  
  905.  * Command: sort-lines REVERSE START END
  906.      This command sorts lines in the region between START and END
  907.      alphabetically.  If REVERSE is non-`nil', the sort is in reverse
  908.      order.
  909.  
  910.  * Command: sort-paragraphs REVERSE START END
  911.      This command sorts paragraphs in the region between START and
  912.      END alphabetically.  If REVERSE is non-`nil', the sort is in
  913.      reverse order.
  914.  
  915.  * Command: sort-pages REVERSE START END
  916.      This command sorts pages in the region between START and END
  917.      alphabetically.  If REVERSE is non-`nil', the sort is in reverse
  918.      order.
  919.  
  920.  * Command: sort-fields FIELD START END
  921.      This command sorts lines in the region between START and END,
  922.      comparing them alphabetically by the FIELDth field of each line.
  923.      Fields are separated by whitespace and numbered starting from 1.
  924.      If FIELD is negative, sorting is by the -FIELDth field from the
  925.      end of the line.  This command is useful for sorting tables.
  926.  
  927.  * Command: sort-numeric-fields FIELD START END
  928.      This command sorts lines in the region between START and END,
  929.      comparing them numerically by the FIELDth field of each line. 
  930.      Fields are separated by whitespace and numbered starting from 1.
  931.      The specified field must contain a number in each line of the
  932.      region.  If FIELD is negative, sorting is by the -FIELDth field
  933.      from the end of the line.  This command is useful for sorting
  934.      tables.
  935.  
  936.  * Command: sort-columns REVERSE &optional BEG END
  937.      This command sorts the lines in the region between BEG and END,
  938.      comparing them alphabetically by a certain range of columns. 
  939.      For the purpose of this command, the region includes the entire
  940.      line that point is in and the entire line containing END.  The
  941.      column positions of BEG and END bound the range of columns to
  942.      sort on.
  943.  
  944.      If REVERSE is non-`nil', the sort is in reverse order.
  945.  
  946.      One unusual thing about this command is that the entire line
  947.      containing point, and the entire line containing the mark, are
  948.      included in the region sorted.
  949.  
  950.      Note that `sort-columns' uses the `sort' utility program, and so
  951.      cannot work properly on text containing tab characters.  Use
  952.      `M-x `untabify'' to convert tabs to spaces before sorting.  The
  953.      `sort-columns' function doesn't work in VMS, because the
  954.      subprocess facilities are lacking.
  955.  
  956.  
  957. 
  958. File: elisp,  Node: Indentation,  Next: Columns,  Prev: Sorting,  Up: Text
  959.  
  960. Indentation
  961. ===========
  962.  
  963.    The indentation functions are used to examine, move to, and change
  964. whitespace that is at the beginning of a line.  Some of the functions
  965. can also change whitespace elsewhere on a line.  Indentation always
  966. counts from zero at the left margin.
  967.  
  968. * Menu:
  969.  
  970. * Primitive Indent::      Functions used to count and insert indentation.
  971. * Mode-Specific Indent::  Customize indentation for different modes.
  972. * Region Indent::         Indent all the lines in a region.
  973. * Relative Indent::       Indent the current line based on previous lines.
  974. * Indent Tabs::           Adjustable, typewriter-like tab stops.
  975. * Motion by Indent::      Move to first non-blank character.
  976.  
  977.  
  978. 
  979. File: elisp,  Node: Primitive Indent,  Next: Mode-Specific Indent,  Prev: Indentation,  Up: Indentation
  980.  
  981. Indentation Primitives
  982. ----------------------
  983.  
  984.    This section describes the primitive functions used to count and
  985. insert indentation.  The functions in the following sections use
  986. these primitives.
  987.  
  988.  * Function: current-indentation
  989.      This function returns the indentation of the current line, which
  990.      is the horizontal position of the first nonblank character.  If
  991.      the contents are entirely blank, then this is the horizontal
  992.      position of the end of the line.
  993.  
  994.  * Command: indent-to COLUMN &optional MINIMUM
  995.      This function indents from point with tabs and spaces until
  996.      COLUMN is reached.  If MINIMUM is specified and non-`nil', then
  997.      at least that many spaces are inserted even if this requires
  998.      going beyond COLUMN.  The value is the column at which the
  999.      inserted indentation ends.
  1000.  
  1001.  * User Option: indent-tabs-mode
  1002.      If this variable is non-`nil', indentation functions can insert
  1003.      tabs as well as spaces.  Otherwise, they insert only spaces. 
  1004.      Setting this variable automatically makes it local to the
  1005.      current buffer.
  1006.  
  1007.  
  1008. 
  1009. File: elisp,  Node: Mode-Specific Indent,  Next: Region Indent,  Prev: Primitive Indent,  Up: Indentation
  1010.  
  1011. Indentation Controlled by Major Mode
  1012. ------------------------------------
  1013.  
  1014.    An important function of each major mode is to customize the TAB
  1015. key to indent properly for the language being edited.  This section
  1016. describes the mechanism of the TAB key and how to control it.  The
  1017. functions in this section return unpredictable values.
  1018.  
  1019.  * Variable: indent-line-function
  1020.      This variable's value is the function to be used by TAB (and
  1021.      various commands) to indent the current line.  The command
  1022.      `indent-according-to-mode' does no more than call this function.
  1023.  
  1024.      In Lisp mode, the value is the symbol `lisp-indent-line'; in C
  1025.      mode, `c-indent-line'; in Fortran mode, `fortran-indent-line'. 
  1026.      In Fundamental mode, Text mode, and many other modes with no
  1027.      standard for indentation, the value is `indent-to-left-margin'
  1028.      (which is the default value).
  1029.  
  1030.  * Command: indent-according-to-mode
  1031.      This command calls the function in `indent-line-function' to
  1032.      indent the current line in a way appropriate for the current
  1033.      major mode.
  1034.  
  1035.  * Command: indent-for-tab-command
  1036.      This command calls the function in `indent-line-function' to
  1037.      indent the current line, except that if that function is
  1038.      `indent-to-left-margin', `insert-tab' is called instead.
  1039.  
  1040.  * Variable: left-margin
  1041.      This variable is the column to which the default
  1042.      `indent-line-function' will indent.  (That function is
  1043.      `indent-to-left-margin'.)  In Fundamental mode, LFD indents to
  1044.      this column.  This variable automatically becomes buffer-local
  1045.      when set in any fashion.
  1046.  
  1047.  * Function: indent-to-left-margin
  1048.      This is the default `indent-line-function', used in Fundamental
  1049.      mode, Text mode, etc.  Its effect is to adjust the indentation
  1050.      at the beginning of the current line to the value specified by
  1051.      the variable `left-margin'.  This may involve either inserting
  1052.      or deleting whitespace.
  1053.  
  1054.  * Command: newline-and-indent
  1055.      This function inserts a newline, then indents the new line (the
  1056.      one following the newline just inserted) according to the major
  1057.      mode.
  1058.  
  1059.      Indentation is done using the current `indent-line-function'. 
  1060.      In programming language modes, this is the same thing TAB does,
  1061.      but in some text modes, where TAB inserts a tab,
  1062.      `newline-and-indent' indents to the column specified by
  1063.      `left-margin'.
  1064.  
  1065.  * Command: reindent-then-newline-and-indent
  1066.      This command reindents the current line, inserts a newline at
  1067.      point, and then reindents the new line (the one following the
  1068.      newline just inserted).
  1069.  
  1070.      Indentation of both lines is done according to the current major
  1071.      mode; this means that the current value of
  1072.      `indent-line-function' is called.  In programming language
  1073.      modes, this is the same thing TAB does, but in some text modes,
  1074.      where TAB inserts a tab, `reindent-then-newline-and-indent'
  1075.      indents to the column specified by `left-margin'.
  1076.  
  1077.  
  1078. 
  1079. File: elisp,  Node: Region Indent,  Next: Relative Indent,  Prev: Mode-Specific Indent,  Up: Indentation
  1080.  
  1081. Indenting an Entire Region
  1082. --------------------------
  1083.  
  1084.    This section describes commands which indent all the lines in the
  1085. region.  They return unpredictable values.
  1086.  
  1087.  * Command: indent-region START END TO-COLUMN
  1088.      This command indents each nonblank line starting between START
  1089.      (inclusive) and END (exclusive).  If TO-COLUMN is `nil',
  1090.      `indent-region' indents each nonblank line by calling the
  1091.      current mode's indentation function, the value of
  1092.      `indent-line-function'.
  1093.  
  1094.      If TO-COLUMN is non-`nil', it should be an integer specifying
  1095.      the number of columns of indentation; then this function gives
  1096.      each line exactly that much indentation, by either adding or
  1097.      deleting whitespace.
  1098.  
  1099.  * Variable: indent-region-function
  1100.      The value of this variable is a function that can be used by
  1101.      `indent-region' as a short cut.  You should design the function
  1102.      so that it will produce the same results as indenting the lines
  1103.      of the region one by one (but presumably faster).
  1104.  
  1105.      If the value is `nil', there is no short cut, and
  1106.      `indent-region' actually works line by line.
  1107.  
  1108.      A short cut function is useful in modes such as C mode and Lisp
  1109.      mode, where the `indent-line-function' must scan from the
  1110.      beginning of the function: applying it to each line would be
  1111.      quadratic in time.  The short cut can update the scan
  1112.      information as it moves through the lines indenting them; this
  1113.      takes linear time.  If indenting a line individually is fast,
  1114.      there is no need for a short cut.
  1115.  
  1116.      `indent-region' with a non-`nil' argument has a different
  1117.      definition and does not use this variable.
  1118.  
  1119.  * Command: indent-rigidly START END COUNT
  1120.      This command indents all lines starting between START
  1121.      (inclusive) and END (exclusive) sideways by `count' columns. 
  1122.      This "preserves the shape" of the affected region, moving it as
  1123.      a rigid unit.  Consequently, this command is useful not only for
  1124.      indenting regions of unindented text, but also for indenting
  1125.      regions of formatted code.
  1126.  
  1127.      For example, if COUNT is 3, this command adds 3 columns of
  1128.      indentation to each of the lines beginning in the region
  1129.      specified.
  1130.  
  1131.      In Mail mode, `C-c C-y' (`mail-yank-original') uses
  1132.      `indent-rigidly' to indent the text copied from the message
  1133.      being replied to.
  1134.  
  1135.  
  1136. 
  1137. File: elisp,  Node: Relative Indent,  Next: Indent Tabs,  Prev: Region Indent,  Up: Indentation
  1138.  
  1139. Indentation Relative to Previous Lines
  1140. --------------------------------------
  1141.  
  1142.    This section describes two commands which indent the current line
  1143. based on the contents of previous lines.
  1144.  
  1145.  * Command: indent-relative &optional UNINDENTED-OK
  1146.      This function inserts whitespace at point, extending to the same
  1147.      column as the next "indent point" of the previous nonblank line.
  1148.      An indent point is a non-whitespace character following
  1149.      whitespace.  The next indent point is the first one at a column
  1150.      greater than the current column of point.  For example, if point
  1151.      is underneath and to the left of the first non-blank character
  1152.      of a line of text, it moves to that column by inserting
  1153.      whitespace.
  1154.  
  1155.      If the previous nonblank line has no next indent point (i.e.,
  1156.      none at a great enough column position), this function either
  1157.      does nothing (if UNINDENTED-OK is non-`nil') or calls
  1158.      `tab-to-tab-stop'.  Thus, if point is underneath and to the
  1159.      right of the last column of a short line of text, this function
  1160.      moves point to the next tab stop by inserting whitespace.
  1161.  
  1162.      This command returns an unpredictable value.
  1163.  
  1164.      In the following example, point is at the beginning of the
  1165.      second line:
  1166.  
  1167.                       This line is indented twelve spaces.
  1168.           -!-The quick brown fox jumped over the lazy dog.
  1169.  
  1170.       Evaluation of the expression `(indent-relative nil)' produces
  1171.      the following:
  1172.  
  1173.                       This line is indented twelve spaces.
  1174.                       -!-The quick brown fox jumped over the lazy dog.
  1175.  
  1176.       In this example, point is between the `m' and `p' of `jumped':
  1177.  
  1178.                       This line is indented twelve spaces.
  1179.           The quick brown fox jum-!-ped over the lazy dog.
  1180.  
  1181.       Evaluation of the expression `(indent-relative nil)' produces
  1182.      the following:
  1183.  
  1184.                       This line is indented twelve spaces.
  1185.           The quick brown fox jum  -!-ped over the lazy dog.
  1186.  
  1187.   * Command: indent-relative-maybe
  1188.      This command indents the current line like the previous nonblank
  1189.      line.  The function consists of a call to `indent-relative' with
  1190.      a non-`nil' value passed to the UNINDENTED-OK optional argument.
  1191.      The value is unpredictable.
  1192.  
  1193.      If the previous line has no indentation, the current line is
  1194.      given no indentation (any existing indentation is deleted); if
  1195.      the previous nonblank line has no indent points beyond the
  1196.      column at which point starts, nothing is changed.
  1197.  
  1198.  
  1199.